<template>
    <ExtForm ref="ExtForm" :formfields="formfields" @changeEventHandler="changeEventHandler"></ExtForm>
</template>
<script>

import defaultSettings from '@/config/defaultSettings'
import pageSetting from '@/components/lt/codeGenerator/pageSetting'
import Vue from 'vue'
import ExtForm from '@/components/lt/codeGenerator/components/ExtForm'
export default {
    name:'MapAttribute',
    components:{ExtForm},
    props:{
        component:{
           type:Object,
           default:()=>{}
        },
    },
    watch:{
        
    },
    data(){
        return{
            defaultSettings,
            formfields:[
                {field:'label',label:'标题',component:pageSetting.常量.表单组件类型.单行文本,initialValue:this.component.label,rules: [{ required: true, message: '不能为空!' }]},
                {field:'ref',label:'ref',component:pageSetting.常量.表单组件类型.单行文本,initialValue:this.component.ref,disabled:true},
                {field:'height',label:'高度',component:pageSetting.常量.表单组件类型.数字输入框,initialValue:this.component.props.height},
            ] 
        }
    },
   
    created(){
        // console.log(this.component)
    },
    methods:{
        changeEventHandler(item){
            if(item["label"]){
                this.component.label=item.label
                for(let i=0;i<this.component.components.length;i++){
                    if(this.component.components[i].type==pageSetting.常量.组件.标题){
                        this.component.components[i].label=item.label
                    }
                }
            }else{
                Vue.set(this.component.props,key,item[key])
            }

        }
    }
}
</script>